import Vue from "vue";
import PayWayPopup from "./index.vue";

export default class PayWayPopupSelect {
  constructor(payWayList, huaBeiInstallment, ratePrice, payWay) {
    this.payWayList = payWayList;
    this.huaBeiInstallment = huaBeiInstallment
    this.ratePrice = ratePrice;
    this.payWay = payWay;
    this.instance = null;
  }
  perform() {
    const PayWayPopupConstructor = Vue.extend(PayWayPopup);
    const instance = new PayWayPopupConstructor({
      propsData: {
        ways: this.payWayList,
        huaBeiInstallment: this.huaBeiInstallment,
        ratePrice: this.ratePrice,
        defaultPayWay: this.payWay
      },
    });
    instance.$mount();
    document.body.appendChild(instance.$el);
    this.instance = instance;
    return instance.showBox();
  }

  close() {
    this.instance?.hideBox();
  }
}
